# coding=utf-8
##
## Author: jmdvirus@aliyun.com
##
## Create: 2019年02月18日 星期一 11时31分59秒
##

from sklearn import preprocessing
import numpy as np

def load_data():
    X = np.array([[1.,-2.,2.],
        [3., 0., 0.],
        [0., 1., -1.]])
    return X

def usage(X):
    ## standardizing features
    x_scaled = preprocessing.scale(X)
    print("x_scaled: ", x_scaled)

    m = x_scaled.mean(axis=0)
    print("x_scaled mean: ", m)

    std = x_scaled.std(axis=0)
    print("x_scaled std: ", std)

    ## normalizing features
    x_normalized_l1 = preprocessing.normalize(X, norm='l1')
    print("x_normalized_l1: ", x_normalized_l1)
    x_normalized_l2 = preprocessing.normalize(X, norm='l2')
    print("x_normalized l2: ", x_normalized_l2)

    min_max_scaler = preprocessing.MinMaxScaler()
    x_min_max = min_max_scaler.fit_transform(X)
    print("x_min_max: ", x_min_max)

    ## binarizing features
    binarizer = preprocessing.Binarizer(threshold=0.5)
    x_binarized = binarizer.transform(X)
    print("x_binarized: ", x_binarized)

if __name__ == "__main__":
    X = load_data()
    usage(X)

